#include <stdlib.h>
#include <stdio.h>
#include <typecomm.h>
#include <logbase.h>
#include <systime.h>
#include <clogConsole.h>
#include <clogFile.h>

int main(int argc, char **argv)
{
    struct clogOutFileInf tmpLogFile;    
    clogOutFileInit(&tmpLogFile);
    clogFileCfgFname(&tmpLogFile, "/tmp/clogChk");
    clogFileCfgFsize(&tmpLogFile, 500 * 1024);
    clogFileCfgFnum(&tmpLogFile, 5);
    clogFileCfgFlush(&tmpLogFile, 1);

    struct clogPrintInfo tmpLogPrtr;
    clogPrintInit(&tmpLogPrtr, CL_LOG_LEV_TRACE, 2048);
    {
        // to console
        struct clogWayInfo tmpway;
        tmpway.fun = clogPrtCslFun;
        tmpway.wayName = "console";
        tmpway.wayUserData = NULL;
        // clogPrintCfgWay(&tmpLogPrtr, tmpway);
        
        // to file
        tmpway.fun = clogPrtFileFun;
        tmpway.wayName = "myfile";
        tmpway.wayUserData = &tmpLogFile;
        clogPrintCfgWay(&tmpLogPrtr, tmpway);
    }

    while(1)
    {
        usleep(10 * 1000);
        clogPrintFunc(&tmpLogPrtr, CL_LOG_LEV_TRACE, __FILE__, __LINE__, "instr:%d", CL_LOG_LEV_TRACE);
        clogPrintFunc(&tmpLogPrtr, CL_LOG_LEV_DEBUG, __FILE__, __LINE__, "instr:%d", CL_LOG_LEV_DEBUG);
        clogPrintFunc(&tmpLogPrtr, CL_LOG_LEV_INFO, __FILE__, __LINE__, "instr:%d", CL_LOG_LEV_INFO);
        clogPrintFunc(&tmpLogPrtr, CL_LOG_LEV_WARN, __FILE__, __LINE__, "instr:%d", CL_LOG_LEV_WARN);
        clogPrintFunc(&tmpLogPrtr, CL_LOG_LEV_ERROR, __FILE__, __LINE__, "instr:%d", CL_LOG_LEV_ERROR);
        clogPrintFunc(&tmpLogPrtr, CL_LOG_LEV_FATAL, __FILE__, __LINE__, "instr:%d", CL_LOG_LEV_FATAL);
    }
    clogPrintQuit(&tmpLogPrtr);
    clogOutFileQuit(&tmpLogFile);
    return 0;
}